package com.user.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exercisesapi.user.PO.TbUser;
import com.exercisesapi.user.UserClient;


import com.user.order.domain.po.Order;
import com.user.order.domain.po.OrderUser;

import com.user.order.mapper.OrederMapper;
import com.user.order.service.OrederService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class OrederServiceImpl extends ServiceImpl<OrederMapper, Order> implements OrederService {
private final OrederMapper orederMapper;
    private final UserClient userClient;
    @Override
    public Order query(Long id) {
        Order order = orederMapper.selectById(id);
        TbUser query = userClient.query(order.getUserId());
        OrderUser orderUser=new OrderUser();
        orderUser.setId(query.getId());
        orderUser.setUsername(query.getName());
        orderUser.setAddress(query.getMobile());
        order.setUser(orderUser);


        return order;

    }
}
